﻿<phone:PhoneApplicationPage 
    x:Class="SSTU.View.TimeTableMenuPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:cm="clr-namespace:System.ComponentModel;assembly=System.Windows"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
	xmlns:sstuBehavior="clr-namespace:SSTU.Controls.Behavior"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
	DataContext="{Binding Path=TimeTableMenuViewModel, Source={StaticResource ViewModelLocator}}">
	
	<phone:PhoneApplicationPage.Resources>
		<CollectionViewSource x:Key="FacultiesSource" Source="{Binding Path=Faculties}">
			<CollectionViewSource.SortDescriptions>
				<cm:SortDescription PropertyName="ShortName" Direction="Ascending" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
	</phone:PhoneApplicationPage.Resources>

	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<toolkit:PerformanceProgressBar IsIndeterminate="{Binding Path=IsBusy}" />
		<TextBlock Margin="24,24,24,0" Grid.Row="1">
			<Run Text="СГТУ" FontSize="{StaticResource PhoneFontSizeLarge}"/>
			<LineBreak></LineBreak>
			<Run Text="расписание" />
		</TextBlock>
		<controls:Pivot Grid.Row="2">
			<controls:PivotItem Header="студентам" Margin="24,0,0,0">
				<ScrollViewer>
					<ItemsControl ItemsSource="{Binding Source={StaticResource FacultiesSource}}" Margin="0,12,0,0">
						<ItemsControl.ItemTemplate>
							<DataTemplate>
								<StackPanel Margin="0,0,24,18" Background="Transparent" sstuBehavior:TiltEffect.IsTiltEnabled="True">
									<toolkit:GestureService.GestureListener>
										<toolkit:GestureListener Tap="OnFacultyItemTap"></toolkit:GestureListener>
									</toolkit:GestureService.GestureListener>
									<TextBlock Text="{Binding Path=ShortName}" FontSize="{StaticResource PhoneFontSizeExtraLarge}"></TextBlock>
									<TextBlock Text="{Binding Path=LongName}" Margin="0,-4,0,0" TextWrapping="Wrap"></TextBlock>
								</StackPanel>
							</DataTemplate>
						</ItemsControl.ItemTemplate>
					</ItemsControl>
				</ScrollViewer>
			</controls:PivotItem>
			<controls:PivotItem Header="избранное" Margin="24,0,0,0">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="*" />
					</Grid.RowDefinitions>
					<TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Margin="0,12,0,12" TextWrapping="Wrap">
						Добавление/удаление производится через конктекстное меню, либо через страницу с расписанием группы.
					</TextBlock>
					<ScrollViewer Grid.Row="2">
						<ItemsControl ItemsSource="{Binding Path=FavoriteGroups}">
							<ItemsControl.ItemTemplate>
								<DataTemplate>
									<StackPanel x:Name="ItemLayoutRoot" Margin="0,0,24,18" Background="Transparent" sstuBehavior:TiltEffect.IsTiltEnabled="True">
										<TextBlock Text="{Binding Path=ShortName}" FontSize="{StaticResource PhoneFontSizeExtraLarge}">
										<toolkit:GestureService.GestureListener>
											<toolkit:GestureListener Tap="OnGroupItemTap"></toolkit:GestureListener>
										</toolkit:GestureService.GestureListener>
										<toolkit:ContextMenuService.ContextMenu>
											<toolkit:ContextMenu>
												<toolkit:MenuItem
													x:Name="FavoriteMenuItem"
													Header="{Binding Path=FavoriteCommandCaption}"
													Command="{Binding Path=TimeTableMenuViewModel.FavoriteCommand, Source={StaticResource ViewModelLocator}}"
													CommandParameter="{Binding Path=.}">
												</toolkit:MenuItem>
											</toolkit:ContextMenu>
										</toolkit:ContextMenuService.ContextMenu>
										</TextBlock>
									</StackPanel>
								</DataTemplate>
							</ItemsControl.ItemTemplate>
						</ItemsControl>
					</ScrollViewer>
				</Grid>
			</controls:PivotItem>
		</controls:Pivot>
	</Grid>

</phone:PhoneApplicationPage>
